import java.rmi.Naming;
import java.rmi.RMISecurityManager;
import java.rmi.server.UnicastRemoteObject;

public class AuctionServer{

	static int port = 1099;
	
	public static void main(String args[]){
		//Create the new AuctionServer
		if (args.length == 1){
			port = Integer.parseInt(args[0]);
		}
		if (System.getSecurityManager() == null){
			System.setSecurityManager(new RMISecurityManager());
		}
		
		try {
			AuctionItemStoreImpl auctionStoreImpl = new AuctionItemStoreImpl();
			AuctionItemStore auctionStore = (AuctionItemStore) UnicastRemoteObject
					.exportObject(auctionStoreImpl, 0);
			Naming.rebind("rmi://localhost:" + port + "/AuctionItemService",
					auctionStore);
			System.out.println("Server loaded: ");
		} catch (Exception e) {
			System.out.println("Server Error: " + e);
		}
	}
	
}